package com.mjlf.swagger_test.controller;

import com.mjlf.swagger_test.entity.Person;
import io.swagger.annotations.*;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName: SwaggerController
 * @Author: majun
 * @CreateDate: 2018/10/16 17:03
 * @Version: 1.0
 * @Description: controller
 */

@RestController
@EnableSwagger2
@RequestMapping("/mjlf")
public class SwaggerController {

    @RequestMapping(value="/test1",method=RequestMethod.GET)
    @ApiOperation(value = "查询个人信息接口",notes = "查询个人信息接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", required = true, type = "Integer", value = "dss")
    })
    //返回结果中无法做到不返回指定字段
    @ApiResponses({
            @ApiResponse(code = 200, message = "I don't know what message", response = Person.class)
    })
    public void query(HttpServletResponse response) {
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("id", "id");
            jsonObject.put("name", "name");
            response.getWriter().write(jsonObject.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
